package pcserver;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;


public class GameData {
	private List<Long> time; 
	private List<Integer> isHint;
	private long point;

	public GameData(String data){
		time = new ArrayList<Long>();
		isHint = new ArrayList<Integer>();
		point = 0;
		File file = new File(data);
		if (file.exists()) {
			FileInputStream fi;
			try {
				fi = new FileInputStream(file);
				InputStreamReader isr = new InputStreamReader(fi, "utf-8");
				BufferedReader bfin = new BufferedReader(isr);
				String rLine = "";
				while ((rLine = bfin.readLine()) != null) {
					if(rLine.equals("")) continue;
					time.add(new Long(Long.parseLong(rLine)));
					isHint.add(new Integer(0));
				}
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (UnsupportedEncodingException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}			
         }
	}

	public int count() {
		// TODO Auto-generated method stub
		return time.size();
	}

	public boolean getIsHint(int i) {
		if(isHint.get(i).intValue() == 0) return false;
		else return true;
	}
	
	public void setIsHint(int i) {
		isHint.set(i, 1);
	}
	
	public long getTime(int i) {
		// TODO Auto-generated method stub
		//System.out.println(time.get(i).longValue());
		return time.get(i).longValue();
	}

	public void addPoint(long point) {
		this.point += point;
	}

	public long getPoint() {
		return point;
	}

}
